package com.chen.lifepic.ThumbnailFragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.chen.lifepic.LifePic;
import com.chen.lifepic.R;
import com.chen.lifepic.DataProvider.RemoteGrideViewProvider;

public class RemoteGrideFragment extends Fragment {
	GridView _gridView = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		_gridView = (GridView) inflater.inflate(
			R.layout.remote_gride_fragemnt, container, false);

		_gridView.setAdapter(new RemoteGrideViewAdapter(this.getActivity(),
			_gridView));

		_gridView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				RemoteGrideViewProvider provider = ((LifePic) getActivity()).getRemoteGrideViewProvider();
				if (null != provider)
					provider.setSelectedIndex(arg2);

				((LifePic) (getActivity())).jumpToFragment(LifePic.FRAGMENT_ID_LARGE_VIEW);
			}
		});
		return _gridView;
	}

	@Override
	public void onResume() {
		super.onResume();
	}
}
